
#递归对dict的key按字母顺序排序
def sorted_dict_full(adict:dict):
    items = list(adict.items())
    items.sort()
    newdict = dict()
    for item in items:
        #print("item:",item)
        sortitem = item[1]
        if type(sortitem) is dict:
            sortitem = sorted_dict_full(sortitem)
        newdict[item[0]]=sortitem
    return newdict


jsondata = '''
{
	"alice": 10,
	"danny": 11,
	"zoo": [
		"tiger",
		"monkey",
		"bird"
	],
	"egg": {
		"alice": 10,
		"danny": 11,
		"carol": 12,
		"bob": 15
	},
	"carol": 12,
	"double": 17,
	"bob": 15
}
'''
import json
dictdata = json.loads(jsondata)

sortdict = sorted_dict_full(dictdata)

print(sortdict)

print(json.dumps(sortdict,indent=4))